var LT = LT || {};

(function ($) {
    $(function () {
        $('input, textarea').placeholder();
    });
}(window.jQuery));

/*
angular.module('ui.config', []).value('ui.config', {});
angular.module('ui.filters', ['ui.config']);
angular.module('ui.directives', ['ui.config']);
LT.app.requires = ['ui.filters', 'ui.directives', 'ui.config'];
*/

LT.Interface = LT.Interface || {};

(function ($) {
    'use strict';

    // Change language
    LT.Interface.LangSelect = function () {
        var
            CONTENT_CLASS = 'header__lang',
            LIST_CLASS = CONTENT_CLASS + '__list',
            LIST_SHOW_CLASS = CONTENT_CLASS + '__list_show',
            ITEM_CLASS = CONTENT_CLASS + '__item',
            $Content = $('.' + CONTENT_CLASS + ':first'),
            $List = $('.' + LIST_CLASS, $Content),
            $Item = $('.' + ITEM_CLASS, $List);

        $Content
            .on('click', function (e) {
                e.stopPropagation();
                $List.toggleClass(LIST_SHOW_CLASS);
            });

        $(document)
            .click(function () {
                $List.removeClass(LIST_SHOW_CLASS);
            })
            .keydown(function (e) {
                if (e.keyCode === 27) {
                    e.preventDefault();
                    $List.removeClass(LIST_SHOW_CLASS);
                }
            });

    };

}(window.jQuery));

!function ($) {
    'use strict';

    var CLASS_ITEM_LEFTMENU = 'n-user-balance-bg',
        TAG_ITEM_LEFTMENU_BALANCE = 'ins';

    LT.Interface.UserBalance = function () {
        $(document.body).on('UserBalance:set', function (e, balance) {
            this.setBalance(balance);
        }.bind(this));
    };

    LT.Interface.UserBalance.prototype = {
        constructor: LT.Interface.UserBalance,

        init: function () {
            this.inited = true;
            this.$LeftMenuBalance = $('.' + CLASS_ITEM_LEFTMENU + ':first ' + TAG_ITEM_LEFTMENU_BALANCE);
        },

        setBalance: function (balance) {
            if (!this.inited) {
                this.init();
            }

            FLRT.user.balance = balance;
            this.$LeftMenuBalance.text(balance);

        }
    };

}(window.jQuery);
